package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.bo.FootListBo;
import com.cskaoyan.bean.pojo.MarketFootprint;
import com.cskaoyan.bean.pojo.MarketUser;
import com.cskaoyan.bean.vo.FootListVO;
import com.cskaoyan.bean.vo.FootprintListVO;
import com.cskaoyan.service.FootPrintService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author :LuoXuXin
 * @version : $version
 * @date :Created in 2022/4/8   23:05
 * @description:
 * @return:
 */
@RestController
@RequestMapping("wx/footprint")
public class FootPrintController {

    @Autowired
    FootPrintService footPrintService;

    @GetMapping("list")
    public BaseRespVo footList(FootListBo footListBo) {
        //如果没有登录  fail  请先登录
        Subject subject = SecurityUtils.getSubject();
        MarketUser principal = (MarketUser) subject.getPrincipal();
        if (principal == null) {
            return BaseRespVo.fail(1000, "登录才能保存历史足迹哦亲");
        }
        FootListVO footListVO = footPrintService.queryAllFoot(footListBo);
        return BaseRespVo.ok(footListVO);
    }

    @PostMapping("delete")
    public BaseRespVo deleteFoot(@RequestBody MarketFootprint marketFootprint) {
        footPrintService.deleteFoot(marketFootprint);
        return BaseRespVo.ok();
    }


}
